import java.util.Random;

/**
 * 加减法口算练习系统-v0.1
 * 生成50道100以内的加法/减法算式
 */
public class CalculationSystemV01 {
    
    public static void main(String[] args) {
        System.out.println("加减法口算练习系统-v0.1");
        System.out.println("==================================");
        
        generateExercises(50);
        
        System.out.println("==================================");
        System.out.println("练习结束！");
    }
    
    /**
     * 生成指定数量的加减法算式习题
     * @param count 习题数量
     */
    public static void generateExercises(int count) {
        Random random = new Random();
        
        for (int i = 1; i <= count; i++) {
            // 随机选择运算类型：0为加法，1为减法
            int operationType = random.nextInt(2);
            
            String exercise;
            if (operationType == 0) {
                // 加法：确保结果不超过100
                int a = random.nextInt(100);
                int b = random.nextInt(101 - a); // 确保a + b <= 100
                exercise = a + " + " + b + " = ";
            } else {
                // 减法：确保结果不为负数
                int a = random.nextInt(100) + 1; // 被减数至少为1
                int b = random.nextInt(a + 1); // 减数不大于被减数
                exercise = a + " - " + b + " = ";
            }
            
            // 输出习题，每行5道题
            System.out.printf("(%2d) %-12s", i, exercise);
            if (i % 5 == 0) {
                System.out.println();
            }
        }
    }
}